﻿using AutoFacPack;
using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DBDesign
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            if (!File.Exists(Application.StartupPath + "\\customcode.s3db"))
            {
                MessageBox.Show("数据库文件丢失\n" + Application.StartupPath + "\\customcode.s3db", "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            AutoFacEngine.Initialize(
                new List<AutoFacRegisterModel>() {
                    new AutoFacRegisterModel() { Assembly = Assembly.Load("RepositoryService"),  RegisterType = RegisterType.IsService, Type = typeof(IService)},
                    new AutoFacRegisterModel() { Assembly = Assembly.Load("Service"),  RegisterType = RegisterType.IsService, Type = typeof(IService)},
                    new AutoFacRegisterModel() { Assembly = Assembly.GetExecutingAssembly(),  RegisterType = RegisterType.IsService, Type = typeof(XtraForm)}
                });
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-Hans");
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            MainForm mainForm = AutoFacEngine.Resolve<MainForm>();
            Application.Run(mainForm);
        }
    }
}
